<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="Generator" content="">
<link rel="icon" type="image/x-icon" href="">
<link rel="stylesheet" type="text/css" href="common.css" media="all">
<link rel="stylesheet" type="text/css" href="log.css" media="all">
<link rel="stylesheet" type="text/css" href="print.css" media="print">
<link rel="stylesheet" type="text/css" href="../common/js_disabled.css" media="all">
<link rel="stylesheet" type="text/css" href="../common/doc_formatting.css" media="all">
<script type="text/javascript" src="log.js"></script>
<script type="text/javascript" src="../lib/jquery.min.js"></script>
<script type="text/javascript" src="../lib/jquery.tmpl.min.js"></script>
<script type="text/javascript" src="../lib/jquery.tablesorter.min.js"></script>
<script type="text/javascript" src="../lib/jsxcompressor.min.js"></script>
<script type="text/javascript" src="fileloading.js"></script>
<script type="text/javascript" src="model.js"></script>
<script type="text/javascript" src="util.js"></script>
<script type="text/javascript" src="testdata.js"></script>
<script type="text/javascript" src="view.js"></script>
<!-- JS MODEL --><script type="text/javascript" src="../testdata/data.js"></script>
<title></title>
</head>
<body>
<div id="javascript-disabled">
  <h1>Opening Robot Framework log failed</h1>
  <ul>
    <li>Verify that you have <b>JavaScript enabled</b> in your browser.</li>
    <li>Make sure you are using a <b>modern enough browser</b>. Firefox 3.5, IE 8, or equivalent is required, newer browsers are recommended.</li>
    <li>Check are there messages in your browser's <b>JavaScript error log</b>. Please report the problem if you suspect you have encountered a bug.</li>
  </ul>
</div>
<script type="text/javascript">removeJavaScriptDisabledWarning();</script>

<div id="header"></div>
<div id="statistics-container"></div>

<script type="text/javascript">
$(document).ready(function() {
    try {
        var topsuite = window.testdata.suite();
    } catch (error) {
        addJavaScriptDisabledWarning(error);
        return;
    }
    initLayout(topsuite.name, 'Log');
    addStatistics();
    addErrors();
    addTestExecutionLog(topsuite);
    addLogLevelSelector(window.settings['minLevel'], window.settings['defaultLevel']);
    if (window.location.hash) {
        makeElementVisible(window.location.hash.substring(1));
    } else {
        expandSuite(topsuite);
    }
});

function addLogLevelSelector(minLevel, defaultLevel) {
    var controller = LogLevelController(minLevel, defaultLevel);
    if (controller.showLogLevelSelector()) {
        var selector = $.tmpl('logLevelSelectorTemplate', controller);
        selector.find('select').val(controller.defaultLogLevel());
        selector.appendTo($('#top-right-header'));
        $('#report-or-log-link').find('a').css({'border-bottom-left-radius': '0'});
        setMessageVisibility(controller.defaultLogLevel());
    }
}

function addErrors() {
    var errors = window.testdata.errorIterator();
    if (errors.hasNext()) {
        $.tmpl('errorHeaderTemplate').appendTo($('body'));
        drawErrorsRecursively(errors, $('#errors'));
    }
}

function drawErrorsRecursively(errors, target) {
    var elements = popFromIterator(errors, 10);
    $.tmpl('errorTemplate', elements).appendTo(target);
    if (errors.hasNext())
        setTimeout(function () { drawErrorsRecursively(errors, target); }, 0);
    else {
        // Errors may have moved scroll position. Resetting location re-scrolls.
        if (window.location.hash)
            window.location.replace(window.location.hash);
        highlightLinkTarget();
    }
}

function highlightLinkTarget() {
    if (window.location.hash) {
        var target = $(window.location.hash);
        highlight(target);
    }
}

function highlight(element, color) {
    if (color === undefined)
        color = 242;
    if (color < 255) {
        element.css({'background-color': 'rgb('+color+','+color+','+color+')'});
        setTimeout(function () { highlight(element, color+1); }, 300);
    } else {
        element.css({'background-color': ''});
    }
}

function popFromIterator(iterator, upTo) {
    var result = [];
    while (iterator.hasNext() > 0 && result.length < upTo)
        result.push(iterator.next());
    return result;
}

function makeElementVisible(id) {
    window.testdata.ensureLoaded(id, function (ids) {
        util.map(ids, expandElementWithId);
        if (ids.length) {
            expandCriticalFailed(window.testdata.findLoaded(util.last(ids)));
            window.location.hash = id;
            highlightLinkTarget();
        }
    });
}

function addTestExecutionLog(main) {
    $('body').append($('<h2>Test Execution Log</h2>'),
                     $.tmpl('suiteTemplate', main));
}
</script>

<script type="text/x-jquery-tmpl" id="totalStatisticsRowTemplate">
  <tr class="row-${$item.index}">
    <td class="stats-col-name">
      <div class="stat-name">
        <span>{{html label}}</span>
      </div>
    </td>
    {{tmpl($data) 'statColumnsTemplate'}}
  </tr>
</script>

<script type="text/x-jquery-tmpl" id="tagStatisticsRowTemplate">
  <tr class="row-${$item.index}">
    <td class="stats-col-name" title="{{html doc}}">
      <div class="stat-name">
        <span>{{html label}}</span>
        {{if info}}(${info}){{/if}}
      </div>
      <div class="tag-links">
        {{each links}}
        <span>[<a href="{{html $value.url}}" title="{{html $value.url}}">{{html $value.title}}</a>]</span>
        {{/each}}
      </div>
    </td>
    {{tmpl($data) 'statColumnsTemplate'}}
  </tr>
</script>

<script type="text/x-jquery-tmpl" id="suiteStatisticsRowTemplate">
  <tr onclick="makeElementVisible('${id}')" class="row-${$item.index}">
    <td class="stats-col-name" title="{{html label}}">
      <div class="stat-name">
        <a href="#${id}"><span class="parent-name">{{html formatParentName}}</span>{{html name}}</a>
      </div>
    </td>
    {{tmpl($data) 'statColumnsTemplate'}}
  </tr>
</script>

<script type="text/x-jquery-tmpl" id="errorHeaderTemplate">
  <h2>Test Execution Errors</h2>
  <table id="errors"></table>
</script>

<script type="text/x-jquery-tmpl" id="errorTemplate">
  <tr id="${id}" class="message-row">
    <td class="error-time">
      {{if link}}
      <a onclick="makeElementVisible('${link}')" href="#${link}" title="Link to details">${date} ${time}</a>
      {{else}}
      ${date} ${time}
      {{/if}}
    </td>
    <td class="${level.toLowerCase()} level"><span class="label ${level.toLowerCase()}">${level}</span></td>
    <td class="message">{{html text}}</td>
    <td class="select-message" onclick="javascript:selectMessage('${id}')" title="Select message text">
      <div></div>
    </td>
  </tr>
</script>

<script type="text/x-jquery-tmpl" id="suiteTemplate">
  <div id="${id}" class="suite">
    <div class="element-header closed" onclick="toggleSuite('${id}')">
      <div class="element-header-left" title="{{html fullName}}">
        <span class="elapsed" title="Elapsed time">${times.elapsedTime}</span>
        <span class="label ${status.toLowerCase()}">SUITE</span>
        <span class="name">{{html name}}</span>
      </div>
      <div class="element-header-right" onclick="stopPropagation(event)" title="">
        <a class="expand" title="Expand all" href="javascript:expandAll('${id}')"></a>
        <a class="collapse" title="Collapse all" href="javascript:collapseAll('${id}')"></a>
        <a class="link" title="Link to this suite" href="#${id}" onclick="makeElementVisible('${id}')"></a>
      </div>
      <div class="element-header-toggle" title="Toggle visibility"></div>
    </div>
    <div class="children">
      <table class="metadata">
        <tr>
          <th>Full Name:</th>
          <td>{{html fullName}}</td>
        </tr>
        {{if doc()}}
        <tr>
          <th>Documentation:</th>
          <td class="doc">{{html doc()}}</td>
        </tr>
        {{/if}}
        {{each metadata}}
        <tr>
          <th>{{html $value[0]}}:</th>
          <td class="doc">{{html $value[1]}}</td>
        </tr>
        {{/each}}
        {{if source}}
        <tr>
          <th>Source:</th>
          {{if relativeSource}}
          <td><a href="${relativeSource}">{{html source}}</a></td>
          {{else}}
          <td>{{html source}}</td>
          {{/if}}
        </tr>
        {{/if}}
        <tr>
          <th>Start / End / Elapsed:</th>
          <td>${times.startTime} / ${times.endTime} / ${times.elapsedTime}</td>
        </tr>
        <tr>
          <th>Status:</th>
          <td>{{tmpl($data) 'suiteStatusMessageTemplate'}}</td>
        </tr>
        {{if message()}}
        <tr>
          <th>Message:</th>
          <td class="message">{{html message()}}</td>
        </tr>
        {{/if}}
      </table>
    </div>
  </div>
</script>

<script type="text/x-jquery-tmpl" id="testTemplate">
  <div id="${id}" class="test">
    <div class="element-header closed" onclick="toggleTest('${id}')">
      <div class="element-header-left" title="{{html fullName}}">
        <span class="elapsed" title="Elapsed time">${times.elapsedTime}</span>
        <span class="label ${status.toLowerCase()}">TEST</span>
        <span class="name">{{html name}}</span>
        {{if !isCritical}}(non-critical){{/if}}
      </div>
      <div class="element-header-right" onclick="stopPropagation(event)" title="">
        <a class="expand" title="Expand all" href="javascript:expandAll('${id}')"></a>
        <a class="collapse" title="Collapse all" href="javascript:collapseAll('${id}')"></a>
        <a class="link" title="Link to this test" href="#${id}" onclick="makeElementVisible('${id}')"></a>
      </div>
      <div class="element-header-toggle" title="Toggle visibility"></div>
    </div>
    <div class="children">
      <table class="metadata">
        <tr>
          <th>Full Name:</th>
          <td>{{html fullName}}</td>
        </tr>
        {{if doc()}}
        <tr>
          <th>Documentation:</th>
          <td class="doc">{{html doc()}}</td>
        </tr>
        {{/if}}
        {{if tags.length}}
        <tr>
          <th>Tags:</th>
          <td>{{html tags.join(', ')}}</td>
        </tr>
        {{/if}}
        {{if timeout}}
        <tr>
          <th>Timeout:</th>
          <td>{{html timeout}}</td>
        </tr>
        {{/if}}
        <tr>
          <th>Start / End / Elapsed:</th>
          <td>${times.startTime} / ${times.endTime} / ${times.elapsedTime}</td>
        </tr>
        <tr>
          <th>Status:</th>
          <td><span class="label ${status.toLowerCase()}">${status}</span> ({{if isCritical}}critical{{else}}non-critical{{/if}})</td>
        </tr>
        {{if message()}}
        <tr>
          <th>Message:</th>
          <td class="message">{{html message()}}</td>
        </tr>
        {{/if}}
      </table>
    </div>
  </div>
</script>

<script type="text/x-jquery-tmpl" id="keywordTemplate">
  <div id="${id}" class="keyword">
    <div class="element-header closed" onclick="toggleKeyword('${id}')">
      <div class="element-header-left" title="{{html name}}">
        <span class="elapsed" title="Elapsed time">${times.elapsedTime}</span>
        <span class="label keyword ${status.toLowerCase()}">${type}</span>
        <span>{{html assign}}</span>
        <span class="name"><span class="parent-name">{{html libname}}{{if libname}} . {{/if}}</span>{{html name}}</span>
        <span class="arg">{{html arguments}}</span>
      </div>
      <div class="element-header-right" onclick="stopPropagation(event)">
        <a class="expand" title="Expand all" href="javascript:expandAll('${id}')"></a>
        <a class="collapse" title="Collapse all" href="javascript:collapseAll('${id}')"></a>
        <a class="link" title="Link to this keyword" href="#${id}" onclick="makeElementVisible('${id}')"></a>
      </div>
      <div class="element-header-toggle" title="Toggle visibility"></div>
    </div>
    <div class="children">
      <table class="metadata keyword-metadata">
        {{if doc()}}
        <tr>
          <th>Documentation:</th>
          <td class="doc">{{html doc()}}</td>
        </tr>
        {{/if}}
        {{if tags}}
        <tr>
          <th>Tags:</th>
          <td>{{html tags}}</td>
        </tr>
        {{/if}}
        {{if timeout}}
        <tr>
          <th>Timeout:</th>
          <td>{{html timeout}}</td>
        </tr>
        {{/if}}
        <tr>
          <th>Start / End / Elapsed:</th>
          <td>${times.startTime} / ${times.endTime} / ${times.elapsedTime}</td>
        </tr>
      </table>
    </div>
  </div>
</script>

<script type="text/x-jquery-tmpl" id="messageTemplate">
  <table id="${id}" class="messages ${level.toLowerCase()}-message">
    <tr class="message-row">
      <td class="time">${time}</td>
      <td class="${level.toLowerCase()} level"><span class="label ${level.toLowerCase()}">${level}</span></td>
      <td class="message">{{html text}}</td>
      <td class="select-message" onclick="javascript:selectMessage('${id}')" title="Select message text">
        <div></div>
      </td>
    </tr>
  </table>
</script>

<script type="text/x-jquery-tmpl" id="logLevelSelectorTemplate">
  <div id="log-level-selector">
  Log level:
    <select onchange="logLevelSelected(this.options[selectedIndex].value)">
      <option value="2">INFO</option>
      <option value="1">DEBUG</option>
      {{if showTrace()}}<option value="0">TRACE</option>{{/if}}
    </select>
  </div>
</script>

</body>
</html>
